<?php

namespace App\Services\ContractSign;

class ContractSignResult
{
    public bool $success;
    public string $message;
    public ?string $code;
    public array $data;
    public array $context;

    public function __construct(bool $success, string $message, ?string $code = null, array $data = [], array $context = [])
    {
        $this->success = $success;
        $this->message = $message;
        $this->code = $code;
        $this->data = $data;
        $this->context = $context;
    }

    public static function success(array $data, string $message = '处理成功', array $context = []): self
    {
        return new self(true, $message, null, $data, $context);
    }

    public static function failure(string $message, ?string $code = null, array $context = []): self
    {
        return new self(false, $message, $code, [], $context);
    }
}
